#ifndef CURVE_ITEM_H
#define CURVE_ITEM_H

/*
Header
*/
#include <QObject>
#include <QColor>
#include <QTreeWidgetItem>
#include <QPolygonF>
#include "qwt_plot.h"
#include "qwt_plot_curve.h"

#define CURVE_LENGEND_INDEX		(1)
#define CURVE_TEXT_INDEX		(2)
#define CURVE_LENGEND_W			(10)
#define CURVE_LENGEND_H			(10)

class CurveItem : public QObject, public QTreeWidgetItem
{
	Q_OBJECT

public:
	CurveItem(QString, QColor);
	~CurveItem();
	void setCurveColor(QColor);
	QColor getCurveColor(void);
	QString getTag(void);
	void addPoint(float y);
	void attachPlot(QwtPlot *plot);
	void detachPlot(void);
	void delPoint(void);
	void reFresh(void);
	void onItemClicked(int column);

	CurveItem& operator=(const CurveItem &other);
#ifndef QT_NO_DATASTREAM  
	friend QDataStream& operator>>(QDataStream &in, CurveItem& data);
	friend QDataStream& operator<<(QDataStream &out, CurveItem& data);
#endif

signals:
	void ColorChanged(QColor);

private:
	QString m_tag;
	QColor m_color;
	QwtPlotCurve m_curve;
	QPolygonF m_points;
	qint32 m_x_cnt;
};

#endif